package com.wenwei.paper.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.wenwei.paper.R;
import com.wenwei.paper.base.Constant;
import com.wenwei.paper.bean.ReplenishmentEndListBean;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/7/13.
 */
public class UserMenuAdapter extends RecyclerView.Adapter<UserMenuAdapter.MyViewHolder> {

    private ArrayList<ReplenishmentEndListBean> mList;
    private Context mContext;

    public void setMenuData(ArrayList<ReplenishmentEndListBean> list) {
        this.mList = list;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        mContext= parent.getContext();
        return new MyViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_user_menu, null));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.replenishmentAddress.setText(mList.get(position).getAddress());
        holder.replenishmentName.setText(mList.get(position).getGoods_name());
        holder.replenishmentNumber.setText("柜号："+mList.get(position).getNum());
        holder.replenishmentTime.setText(mList.get(position).getTime());
        holder.replenishmentCount.setText("x "+mList.get(position).getCount());
        Glide.with(mContext).load(Constant.BASE_IMG_URL+mList.get(position).getGoods_img()).into(holder.replenishmentImage);
    }

    @Override
    public int getItemCount() {
        return mList == null ? 0:mList.size();
    }

    public static class MyViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.replenishment_number)
        TextView replenishmentNumber;
        @Bind(R.id.replenishment_state)
        TextView replenishmentState;
        @Bind(R.id.replenishment_image)
        ImageView replenishmentImage;
        @Bind(R.id.replenishment_name)
        TextView replenishmentName;
        @Bind(R.id.replenishment_time)
        TextView replenishmentTime;
        @Bind(R.id.replenishment_address)
        TextView replenishmentAddress;
        @Bind(R.id.replenishment_count)
        TextView replenishmentCount;
        public MyViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

}
